package com.robusta.app.catalogue.model;

import com.robusta.app.domain.YesNo;
import com.robusta.app.domain.catalogue.CatalogueType;
import com.robusta.app.model.persistence.AuditListener;
import com.robusta.app.model.persistence.Creatable;
import com.robusta.app.model.persistence.Updatable;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

@Entity
@Table(name = "CATALOGUE") @EntityListeners(AuditListener.class)
public class CatalogueModel extends com.robusta.app.model.persistence.Entity implements Serializable, Creatable, Updatable {
    @Id
    @Column(name = "CATALOGUE_ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    @Column(name = "DISPLAY_NAME", nullable = false)
    private String displayName;
    @Column(name = "VERSION", nullable = false)
    private String version;
    @Column(name = "TYPE", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private CatalogueType catalogueType;
    @Column(name = "ACTIVE", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private YesNo active;
    @OneToMany(cascade= CascadeType.ALL, mappedBy="catalogue")
    private List<CatalogueEntryModel> entries;

    public CatalogueModel() {
    }
}
